#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h> 
#include <stdlib.h>
typedef struct worker {
    char name[20];
    int wage;
    struct worker* next;
}node;



struct worker* del_list(node* list, int x)
{
    if (list == NULL) {
        return NULL;
    }
    if (list->wage == x) {
        node* tmp = list;
        list = list->next;
        free(tmp);
        return list;
    }
    node* cur = list;
    while (cur->next != NULL) {
        if (cur->next->wage == x) {
            node* tmp = cur->next;
            cur->next = cur->next->next;
            free(tmp);
            break;
        }
        cur = cur->next;
    }
    return list;
}




int main()
{
    node* list, * p = NULL, * q = NULL, * tail = NULL;
    char name[20];
    int wage, n = 0;

    struct worker* del_list(node * list, int x);

    list = NULL;
    printf("Please fill in name and wage:\n");
    scanf("%s%d", name, &wage);

    while (wage != 0)
    {
        n++;
        p = (node*)malloc(sizeof(node));

        strcpy(p->name, name);
        p->wage = wage;
        p->next = NULL;

        if (n == 1) list = p;
        else tail->next = p;
        tail = p;
        scanf("%s%d", name, &wage);
    }

    int x;
    printf("please fill in the special wage:\n");
    scanf("%d", &x);

    list = del_list(list, x);

    node* k;

    printf("the final list is:\n");
    for (k = list; k != NULL; k = k->next)
    {
        printf("%s,%d\n", k->name, k->wage);
    }

    return 0;
}